#{extends 'mainFMPA.html' /} #{set title:'Détail de la FMPA' /}
#{if !fmpa.etat.id_etatfmpa.equals("ATVAL") || (fmpa.etat.id_etatfmpa.equals("ATVAL") && (agent_responsable || chef_CIS || admin))}
<br />
<h1 style="width: 400px;">D&eacute;tails de la FMPA</h1>
#{if !fmpa.etat.id_etatfmpa.equals("TERMI")}
<p>
	<a href="@{FMPAs.modifFMPAForm(fmpa.id)}">Modifier la FMPA</a>
</p>
#{/if}

<div id="detail_fmpa">
	<p>
		<label><b> CIS : </b>
		</label>
		${fmpa.cis}
	</p>
	<p>
		<label><b> Date : </b>
		</label>
		${fmpa.date.format('dd MMMM yyyy', 'fr')}
	</p>
	<p>
		<label><b> Th&eacute;matique : </b>
		</label>
		${fmpa.thematique}
	</p>
	<p>
		<label><b> Th&egrave;me : </b>
		</label> 
		#{if fmpa.sousThematique.equals("") || fmpa.sousThematique==null}
		 - 
		#{/if}
		#{else}
		${fmpa.sousThematique}
		#{/else}
	</p>
	<p>
		<label><b> Description : </b>
		</label> 
		#{if fmpa.description.equals("") || fmpa.description==null}
		 - 
		#{/if}
		#{else}
		${fmpa.description}
		#{/else}
	</p>
	<p>
		<label><b> Observations : </b>
		</label>
		#{if fmpa.observation.equals("") || fmpa.observation==null}
		 - 
		#{/if}
		#{else}
		${fmpa.observation}
		#{/else}
	</p>
	<p>
		<label><b> Dur&eacute;e : </b>
		</label>
		${fmpa.duree}
	</p>
	<p>
		<label><b> Etat : </b>
		</label>
		#{if fmpa.etat == null} - 
		#{/if} 
		#{else} ${fmpa.etat} 
		#{/else}
	</p>
	<p>
		<label><b> Effectif actuel : </b>
		</label>
		#{if fmpa.getEffectif() == 0} - 
		#{/if} 
		#{else} ${fmpa.getEffectif()}
		#{/else}
	</p>
	#{if fmpa.etat.id_etatfmpa.equals("PREVU") || fmpa.etat.id_etatfmpa.equals("INVAL")}
		#{form @demandeValid(fmpa.id)}
        <center><input type="submit" value="Demander la validation" /></center>
        #{/form}
    #{/if}
    #{if fmpa.etat.id_etatfmpa.equals("ATVAL")}
        <center><input type="button" onClick="self.location.href='@{FMPAs.validerFMPA(true,fmpa.id)}'" value="valider" /> <input type="button" onClick="self.location.href='@{FMPAs.validerFMPA(false,fmpa.id)}'" value="refuser" /></center>
    #{/if}
</div>

<div id="detail_fmpa_participants">
	<br />
	#{if isParticipant}
	<h2 style="float: left;">Liste des participants</h2>
	<br />
	#{if !fmpa.etat.id_etatfmpa.equals("TERMI")}
	<input style="float: right;" type="button" onClick="self.location.href='@{FMPAs.validerTous(fmpa.id)}'" value="tout valider" />
	#{/if}
	<br />
	<table width="200" cellspacing='0' cellpadding='7' id="liste"
		class="display" summary="Liste des candidats" bgcolor="#E1EEF0">
		<thead>
			<tr>
				<th>Nom</th>
				<th>Pr&eacute;nom</th>
				<th>Grade</th>
				<th>Statut</th>
				<th>CIS</th>
				<th>R&ocirc;le</th>
				<th>FMPA valid&eacute;e</th>
				#{if !fmpa.etat.id_etatfmpa.equals("TERMI")}
				<th>validation</th>
				#{/if}
			</tr>
		</thead>
		<tbody>
			#{list items:participants, as:'participant' }
			<tr>
				<td>${participant.agent.nom}</td>
				<td>${participant.agent.prenom}</td>
				<td>${participant.agent.grade}</td>
				<td>${participant.agent.statut}</td>
				<td>${participant.agent.cisService}</td>
				<td>${participant.role}</td>
				#{if participant.valide}
					<td>valide
				#{/if}
				#{else}
					<td class="attention">non valide
				#{/else}
				</td>
				#{if !fmpa.etat.id_etatfmpa.equals("TERMI")}
				<td><a href="@{FMPAs.valider(participant.id,true,fmpa.id)}">valider</a><br />
					<a href="@{FMPAs.valider(participant.id,false,fmpa.id)}">invalider</a><br />
					<a href="@{FMPAs.retirerParticipant(participant.id,fmpa.id)}">annuler</a>
				</td>
				#{/if}
			</tr>
			#{/list}
		<tbody>
	</table>
	#{/if}
	#{if !fmpa.etat.id_etatfmpa.equals("TERMI")}
	</br>
	<div id="ajout">
	#{form @newParticipantSave()}
	<p>
		<label for="cis"><b>CIS :</b></label> 
		#{select 'cis', items:ciss, id:'cis', valueProperty:'id', value:idCis, onChange:'change()'}
		#{/select}
	</p>
	<p id="aModifier">
		<label for="agent"><b>Agent :</b></label>
		#{select 'agent', items:agents,id:'agent', value:'0'}
		#{/select}
	</p>
	<p>
		<label for="role"><b>role :</b></label>
		#{select 'role', items:roles, valueProperty:'id', value:idForme}
		#{/select}
	</p>
	<input type="hidden" name="fmpa" value=${fmpa.id} >
	<center><input type="submit" value="Ajouter l'agent"></center>
	#{/form}
	</div>
	#{/if}
</div>
#{/if} #{else}
<div class="empty">Cette fmpa est en attente de validation. Vous ne pouvez pas consulter cette page.</div>
#{/else}

<SCRIPT type="text/javascript">
	function change(){
	    var monCis=document.getElementById("cis").options[document.getElementById("cis").selectedIndex].value
	    $('#aModifier').load("/attraper/"+monCis)
	}
</SCRIPT>

<SCRIPT type="text/javascript">
	
	function validerFMPA(){
		load(@{FMPAs.validerFMPA(true,fmpa.id)});
	}
	
	function refuserFMPA(){
		load(@{FMPAs.validerFMPA(false,fmpa.id)});
	}
</SCRIPT>